<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Qiniu\Storage;

class ArgusManager
{
    private $auth;
    private $config;
    public function __construct(\Qiniu\Auth $auth, \Qiniu\Config $config = NULL)
    {
        $this->auth = $auth;
        if($config == NULL) {
            $this->config = new \Qiniu\Config();
        } else {
            $this->config = $config;
        }
    }
    public function pulpVideo($body, $vid)
    {
        $path = "/v1/video/" . $vid;
        return $this->arPost($path, $body);
    }
    private function getArHost()
    {
        $scheme = "http://";
        if($this->config->useHTTPS) {
            $scheme = "https://";
        }
        return $scheme . \Qiniu\Config::ARGUS_HOST;
    }
    private function arPost($path, $body = NULL)
    {
        $url = $this->getArHost() . $path;
        return $this->post($url, $body);
    }
    private function post($url, $body)
    {
        $headers = $this->auth->authorizationV2($url, "POST", $body, "application/json");
        $headers["Content-Type"] = "application/json";
        $ret = \Qiniu\Http\Client::post($url, $body, $headers);
        if(!$ret->ok()) {
            echo $ret->statusCode;
            return [NULL, new \Qiniu\Http\Error($url, $ret)];
        }
        $r = $ret->body === NULL ? [] : $ret->json();
        return [$r, NULL];
    }
}

?>